﻿@using HGShare.Site
@using HGShare.Site.Config
@using HGShare.VWModel
@using Webdiyer.WebControls.Mvc
@model PagedList<ArticleVModel>
@{
    ViewBag.Title = "主题列表";
    Layout = "~/Views/Shared/_HContentLayout.cshtml";
}
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>主题列表</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form action="@Url.Action("Index", "Articles")" method="GET">
                        <div class="row">
                            <div class="col-sm-5 m-b-xs">
                                <div class="btn-group hidden-xs" role="group">
                                    <a href="@Url.Action("Add","Articles")" class="btn btn-outline btn-default" title="添加">
                                        <i class="fa fa-pencil-square" aria-hidden="true"></i> 添加
                                    </a>
                                    <button class="btn btn-default btn-outline" type="button" name="refresh" title="刷新" id="pagereload">
                                        <i class="fa fa-refresh"></i> 刷新
                                    </button>
                                    <button type="button" class="btn btn-outline btn-default" id="deletessubmit" title="删除选中项">
                                        <i class="fa fa-trash" aria-hidden="true"></i> 删除
                                    </button>
                                    <button type="button" class="btn btn-outline btn-default" id="verifiedsubmit" title="通过审核选中项">
                                        <i class="fa fa-check" aria-hidden="true"></i> 通过
                                    </button>
                                    <button type="button" class="btn btn-outline btn-default" id="noverifiedsubmit" title="不通过审核选中项">
                                        <i class="fa fa-close" aria-hidden="true"></i> 拒绝
                                    </button>
                                </div>
                            </div>
                            <div class="col-sm-4 m-b-xs">
                                <!--其它搜索条件-->
                            </div>
                            <div class="col-sm-3">
                                <div class="input-group">
                                    <input type="hidden" name="page" value="1" />
                                    <input type="text" placeholder="请输入关键词" class="input-sm form-control">
                                    <span class="input-group-btn">
                                        <button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
                                    </span>
                                </div>
                            </div>
                        </div>
                    </form>
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                                <tr>
                                    <th>
                                        <div class="checkbox checkbox-inline checkbox-primary">
                                            <input type="checkbox" value="0" id="selectitem" />
                                            <label for="selectitem"></label>
                                        </div>
                                    </th>
                                    <th>编号</th>
                                    <th>标题</th>
                                    <th>类型</th>
                                    <th>评论数</th>
                                    <th>浏览量</th>
                                    <th>创建用户</th>
                                    <th>修改用户</th>
                                    <th>置顶</th>
                                    <th>精华</th>
                                    <th>关闭评论</th>
                                    <th>审核通过</th>
                                    <th>添加时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach (ArticleVModel item in Model)
                                {
                                    <tr>
                                        <td>
                                            <div class="checkbox checkbox-inline checkbox-primary">
                                                <input type="checkbox" value="@item.Id" id="item_@item.Id" name="item" class="form-control" />
                                                <label for="item_@item.Id"></label>
                                            </div>
                                        </td>

                                        <td>@item.Id</td>
                                        <td><a href="@Url.BbsWebAction("Detail", "Article",new{aid=item.Id})" target="_blank">@item.Title</a></td>
                                        <td>@item.TypeName</td>
                                        <td>@item.CommentNum</td>
                                        <td>@item.Dot</td>
                                        <td>@item.UserName</td>
                                        <td>@item.LastEditUserName</td>
                                        <td>
                                            <input type="checkbox" data-id="@item.Id" class="isstick-switch" @(item.IsStick ? "checked" : "") title="@(item.IsStick ? "置顶" : "未置顶")" />
                                        </td>
                                        <td>
                                            <input type="checkbox" data-id="@item.Id" class="isjiajing-switch" @(item.IsJiaJing ? "checked" : "") title="@(item.IsJiaJing ? "精华" : "非精华")" />
                                        </td>
                                        <td>
                                            <input type="checkbox" data-id="@item.Id" class="isclosecomment-switch" @(item.IsCloseComment ? "checked" : "") title="@(item.IsCloseComment ? "已关闭" : "未关闭")" />
                                        </td>
                                        <td>
                                            <input type="checkbox" data-id="@item.Id" class="state-switch" @(item.State == 1 ? "checked" : "") title="@(item.State == 1 ? "已通过" : item.State == 2 ? "未通过" : "未审核")"/>
                                        </td>
                                        <td>@item.CreateTime</td>
                                        <td>
                                            <a class="btn btn-info btn-sm" href="@Url.Action("Edit","Articles")?Id=@item.Id"><i class="fa fa-paste"></i> 编辑</a>
                                            <button class="btn btn-warning btn-sm delete_btn" type="button" data-id="@item.Id">
                                                <i class="fa fa-warning"></i> <span class="bold">删除</span>
                                            </button>
                                        </td>
                                    </tr>
                                }
                            </tbody>
                        </table>
                    </div>

                </div>
            </div>
        </div>

    </div>
    <div class="row">
        <div class="col-sm-6">
            <div class="dataTables_info">共 @Model.TotalItemCount 项 @Model.TotalPageCount 页，当前第 @Model.CurrentPageIndex 页</div>
        </div>
        <div class="col-sm-6">
            <div class="dataTables_paginate paging_simple_numbers">
                <ul class="pagination">
                    @Html.Pager(Model, PageConfig.BackstageOptions)
                </ul>
            </div>
        </div>
    </div>
</div>
@section script_header
{
    <!--切换开关插件-->
    <link href="@Url.StaticFile("~/hplus/css/plugins/switchery/switchery.css")" rel="stylesheet">
}
@section script_footer
{
    <!--切换开关插件-->
    <script type="text/javascript" src="@Url.StaticFile("~/hplus/js/plugins/switchery/switchery.js")"></script>
    <script type="text/javascript">
    $(function() {
        /*通用删除操作*/
        ListTools.Delete.Init({ url: "@Url.Action("Delete", "Articles")", btn: ".delete_btn" });
        /*通用多选删除操作*/
        ListTools.Deletes.Init({ url: "@Url.Action("Deletes", "Articles")", btn: "#deletessubmit", itemname: "item" });
        /*选择操作*/
        ListTools.SelectBox.Init({ btn: "#selectitem", itemname: "item" });
        /*刷新操作*/
        ListTools.PageReload.Init({ btn: "#pagereload" });
        //批量通过操作
        ListTools.BatchAction.Init({
            btn: '#verifiedsubmit',
            callback: function(ids) {
                hgajax.post("@Url.Action("Verifieds", "Articles")", { ids: ids, state: true }, tabTools.TabPageReload);
            }
        });
        //批量拒绝操作
        ListTools.BatchAction.Init({
            btn: '#noverifiedsubmit',
            isinputtext: true,
            inputtexttitle:'输入拒绝通过原因',
            callback: function(ids) {
                hgajax.post("@Url.Action("Verifieds", "Articles")", { ids: ids, state: false, reason: escape(text) }, tabTools.TabPageReload);
            }
        });
        /*
        *评论开关
        *关闭时输入 理由
        */
        (function() {
            var kaiQi = function(id) {
                hgajax.postNoAlert("@Url.Action("CloseComment", "Articles")", { id: id, isCloseComment: false });
            };
            var guanBi = function(id) {
                hgajax.postNoAlert("@Url.Action("CloseComment", "Articles")", { id: id, isCloseComment: true, reason: escape("暂无！") });
                layer.prompt({ title: '输入原因', formType: 2 }, function(text, index) {
                    layer.close(index);
                    hgajax.postNoAlert("@Url.Action("CloseComment", "Articles")", { id: id, isCloseComment: true, reason: escape(text) });
                });
            };
            switcheryTools.InitItems('.isclosecomment-switch', function () {
                var id = $(this).attr("data-id");
                this.checked ? guanBi(id) : kaiQi(id);
            });
        })();

        /***************************************************/
        /*
        *状态开关 开 state=1 关 state=2
        *关闭时输入 理由
        */
        (function() {
            switcheryTools.InitItems('.state-switch', function() {
                var dataid = $(this).attr("data-id");
                this.checked ?
                (function(id) {
                    //通过
                    hgajax.postNoAlert("@Url.Action("Verified", "Articles")", { id: id, state: true });
                })(dataid) :
                (function(id) {
                    //拒绝
                    hgajax.postNoAlert("@Url.Action("Verified", "Articles")", { id: id, state: false, reason: escape("暂无！") });
                    layer.prompt({ title: '输入拒绝通过原因', formType: 2 }, function(text, index) {
                        layer.close(index);
                        hgajax.postNoAlert("@Url.Action("Verified", "Articles")", { id: id, state: false, reason: escape(text) });
                        });
                    })(dataid);
                });
        })();
        //文章加精/取消加精
        (function() {
            var xuanZhong = function(id) {
                hgajax.postNoAlert("@Url.Action("IsJiaJing", "Articles")", { id: id, state: true });
            };
            var quXiao = function(id) {
                hgajax.postNoAlert("@Url.Action("IsJiaJing", "Articles")", { id: id, state: false });
            };
            switcheryTools.InitItems('.isjiajing-switch', function() {
                var id = $(this).attr("data-id");
                this.checked ? xuanZhong(id) : quXiao(id);
            });
        })();
        //文章置顶/取消置顶
        (function() {
            var xuanZhong = function(id) {
                hgajax.postNoAlert("@Url.Action("IsStick", "Articles")", { id: id, state: true });
            };
            var quXiao = function(id) {
                hgajax.postNoAlert("@Url.Action("IsStick", "Articles")", { id: id, state: false });
            };
            switcheryTools.InitItems('.isstick-switch', function() {
                var id = $(this).attr("data-id");
                this.checked ? xuanZhong(id) : quXiao(id);
            });
        })();
    })
    </script>
}











